fix: Do not reconnect on rerender#253
Conversation
|
might also fix #254 |
|
This seems to fix #254 |
pulkitsharma07
left a comment
There was a problem hiding this comment.
cc @cliffhall for review
|
I think better thing to do here is to remove |
|
@pulkitsharma07 I was eyeing the same, but I'm also trying to understand if there was something else that exposed the issue since I believe we tested the oauth flow with that PR before merging. I am putting together a few test scenarios using a couple of the snippets shared for reproducing these issues that could help ensure that we're not just playing whack a mole here. |
|
I'm not a FE engineer by trade so take these comments with a grain of salt:
|
|
Created an alternative approach to solving the immediate problem here: #259 @max-stytch your suggestions sound like good options. I'll create an issue to make sure we have a place to track those medium-term to longer-term suggestions. As someone who is also not a FE engineer by trade it would be great to get more perspective on the best options here. |
The hooks rule that any function used in a hook should be passed in as a dep is the rock. The fact that each rerender recreates the function and runs it again is the hard place. The fix here is that we have a durable flag (the ref) that can tell us whether the thread of execution has passed through this hook in the past, allowing us to only execute it once. |
fix: Do not reconnect on rerender

Fixes a bug where the
useEffectthat wrapsconnectMcpServerruns repeatedly becauseconnectMcpServeritself is not a stable callback reference. Every time the app re-renders,connectMcpServeris a different function, triggering theuseEffectto run again.I think this fixes #250 - it certainly makes things much more stable for me though I have been getting a few scattered
ENOENTerrors as well.Motivation and Context
Fixes a bug where the
useEffectruns over and over and reconnects several times, which tends to overload the proxy and cause it to 500.How Has This Been Tested?
The old clicky clicky against my existing MCP servers
Breaking Changes
Types of changes
Checklist
Additional context